package com.itcast.mapper;

import com.itcast.pojo.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.stereotype.Repository;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ${author}
 * @since 2020-06-19
 */
@Repository
@Mapper
public interface UserMapper extends BaseMapper<User> {
    User login(User user);//登录

    /**
     * 修改密码
     * @param pwd
     * @param phone
     * @return
     */

    int updatePwd(@Param("pwd") String pwd , @Param("phone") String phone);

    @Select(value = "select * from user where phone=#{phone} and password=#{password}")
    User select(@Param("phone")String  phone,@Param("password") String password);


    @Insert("insert into user(uid,password) value (#{uid},#{password})")
    User insert(@Param("userName")String  userName,@Param("password") String password);

    @Insert("insert into user(userName,password,phone) value (#{phone},#{password},#{phone})")
    int register(@Param("phone") String phone, @Param("password") String password);

    @Update("UPDATE user SET userName=#{user.userName},city=#{user.city},age=#{user.age},signature=#{user.signature},phone=#{user.phone},occupation=#{user.occupation},income=#{user.income} WHERE uid = #{user.uid}")
    int updateUserInfo(@Param("user") User user);

    @Update("UPDATE user SET password = #{password} WHERE uid = #{uid}")
    int updateUserPassword(@Param("uid") String uid, @Param("password") String password);
}